// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'normalize.css'
import './assets/iconfont/iconfont.css'

// === 引入 vue-echarts 和 echarts 核心 + 图表类型 ===
import VChart from 'vue-echarts'
import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { LineChart, BarChart, PieChart } from 'echarts/charts'
import {
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  GridComponent
} from 'echarts/components'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import UploadImage from '@/components/UploadImage.vue'

// 注册 ECharts 模块
use([
  CanvasRenderer,
  LineChart,
  BarChart,
  PieChart,
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  GridComponent
])

const app = createApp(App)
app.use(createPinia())
app.use(router)
app.use(ElementPlus)

// 注册全局组件
app.component('v-chart', VChart)

app.component('UploadImage', UploadImage)

app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.mount('#app')
